import demos from "@/src/index"
let {towerCrane} = demos as any;
window.onload = function(){
  let buildingSite = towerCrane({
    contenter:this.document.querySelector('#towerCrane')
  });
  let towerCranes = [
    {
      id: 'demo1',
      position: {
        x: 100,
        y: 100
      },
      radius: 50,
      angle: 90,
      controlRoom: 20
    },
    {
      id: 'demo2',
      position: {
        x: 300,
        y: 100
      },
      radius: 80,
      angle: 120,
      controlRoom: 30
    },
    {
      id: 'demo3',
      position: {
        x: 230,
        y: 250
      },
      radius: 80,
      angle: 200,
      controlRoom: 40
    },
    {
      id: 'demo4',
      position: {
        x: 100,
        y: 250
      },
      radius: 75,
      angle: 30,
      controlRoom: 40
    },
    {
      id: 'demo5',
      position: {
        x: 100,
        y: 350
      },
      radius: 60,
      angle: 30,
      controlRoom: 40
    },
    {
      id: 'demo6',
      position: {
        x: 200,
        y: 350
      },
      radius: 60,
      angle: 30,
      controlRoom: 40
    },
    {
      id: 'demo7',
      position: {
        x: 250,
        y: 100
      },
      radius: 60,
      angle: 30,
      controlRoom: 40
    }
  ];
  buildingSite.updata(towerCranes);
  setInterval(()=>{
    towerCranes.forEach(item=>{
      item.angle+=5;
      item.controlRoom +=0.5;
      if(item.controlRoom >= item.radius){
        item.controlRoom = 0;
      }
    });
    buildingSite.updata(towerCranes);
  },30)
}